import random

from rest_framework.permissions import BasePermission

from ext import http_code


class UserPermission(BasePermission):
    message = {"code": http_code.ERROR_PERMISSION, "message": "无权限访问"}

    def has_permission(self, request, view):
        # v1 = random.randrange(1, 5)
        # print("has_object_permission", v1)
        # if v1 > 3:
            return True
        # else:
        #     return False
